import request from '@/utils/request.js'

// 用户登录
export const userLogin = (userInfo) => {
  return request.post('/login', userInfo)
}

// 用户注册
export const userRegister = (userInfo) => {
  return request.post('/register', userInfo)
}

// 获取验证码
export const getVerifyCode = () => {
  return request.get('/generateCaptcha')
}

// 获取用户信息
export const getUserInfo = (userId) => {
  return request.get(`/getUserInfo/${userId}`)
}

// 更新用户信息
export const updateUserInfo = (userInfo) => {
  return request.put('/updateUserInfo', userInfo)
}

// 校验密码
export const checkPassword = (id, password) => {
  return request.get('/checkPwd', {
    params: {
      id,
      password
    }
  })
}

// 退出登录，删除redis中的缓存
export const logout = () => {
  return request.delete('/logout')
}
